package com;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.api.gbhg.daizhishun.service.AccountingRoleServiceImpl;
import com.api.gbhg.huangpeng.api.YusuanApi;
import com.api.gbhg.lbj.api.ImportExcelApi;
import com.api.gbhg.lbj.api.ImportExcelApiV2;
import com.api.gbhg.lbj.api.SubmitAmountVerificationApi;
import com.api.gbhg.lbj.api.UserQuotaCheckApi;
import com.api.gbhg.lbj.dao.ExcelDao;
import com.api.gbhg.lbj.dao.ReimbursementDao;
import com.api.gbhg.liuwenbo.api.*;
import com.api.gbhg.liuwenbo.dao.DataBaseUtil;
import com.api.gbhg.liuwenbo.version3.api.AdministrationApi3;
import com.api.gbhg.liwenjun.GBHGConstant;
import com.api.gbhg.liwenjun.VersionFlowUtil;
import com.api.gbhg.luoao.la.dao.BudgetModifyDao;
import com.api.gbhg.luoao.tool.ToolCURD;
import com.api.gbhg.luoao.web.HeadcquartersApi;
import com.api.gbhg.luoao.web.Reimbursementlist;
import com.api.gbhg.wangc.api.BudgetManagementApi;
import com.api.gbhg.xxd.api.BaoXiaoJiLu;
import com.api.gbhg.xxd.api.BudgetExecutionNotice;
import com.api.gbhg.xxd.api.TheCashierToPay;
import com.api.gbhg.zengping.common.CommonDao;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import com.api.gbhg.zengping.web.BudgetingListAction;
import com.customization.assets.formmode.sync.SyncAssetsInfoToEcology;
import com.google.common.base.Joiner;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;

import weaver.conn.RecordSet;
import weaver.conn.RecordSetDataSource;
import weaver.conn.RecordSetTrans;
import weaver.general.BaseBean;
import weaver.general.GCONST;
import weaver.hrm.User;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.soa.workflow.request.DetailTable;
import weaver.workflow.request.RequestInfo;
import weaver.workflow.workflow.WorkflowVersion;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.regex.Pattern;


public class test {

    @Test
    public  static void  main(String args[]) throws Exception {
        String rootPath = "D:\\WEAVER\\ecology\\";
        GCONST.setRootPath(rootPath);
        GCONST.setServerName("ecology");

//        YusuanApi yusuanApi = new YusuanApi();
//        System.err.println(yusuanApi.getZcgnkm("28_81"));

//        String sql1 = "select uf_jingfei_version.requestid,workflow_bill.tablename from uf_jingfei_version\n" +
//                "left join workflow_requestbase \n" +
//                "on uf_jingfei_version.lcjlsqjlid=workflow_requestbase.requestid\n" +
//                "left join workflow_base\n" +
//                "on workflow_requestbase.workflowid=workflow_base.id\n" +
//                "left join workflow_bill\n" +
//                "on workflow_base.formid=workflow_bill.id";
//        RecordSet rs1 = new RecordSet();
//        RecordSet rs2 = new RecordSet();
//        rs1.execute(sql1);
//        while (rs1.next()){
//            String requestid = rs1.getString("requestid");
//            String tablename = rs1.getString("tablename");
//            rs2.execute("update uf_jingfei_version set dlhsdw=(select convert(int,convert(varchar,szdlhsdw)) from "+tablename+" where requestid="+requestid+") where requestid="+requestid);
//        }

//        Map<String, Object> param = new HashMap<>();
//        param.put("lcid", "876363");
//        param.put("zcqd", "876363");
//        param.put("lcid", "876363");
//        BudgetManagementApi api = new BudgetManagementApi();
//        Map<String, Object> param = new HashMap<>();
//        param.put("proName","");
//        param.put("unitName","");
//        param.put("startDate","");
//        param.put("endDate","");
//        param.put("pageNum",1);
//        param.put("pageSize",10);
//        param.put("userid","13939");
//        param.put("sbdw","");
//        System.err.println(api.getProjectAccountList(param));

//        bmjjzcfl: "30101"
//        detaileId: 0
//        fzysrfl: ""
//        jbbm: "6"
//        nd: "2022"
//        szdlhsdw: "6"
//        tybxje: "126340.00"
//        xzkmdm: "596"
//        ysly: "0"
//        ysxm: "580666"
//        zcdfczbkxm: ""
//        zcqd: "0"
//        bmjjzcfl: "30101"
//        detaileId: 1
//        fzysrfl: ""
//        jbbm: "6"
//        nd: "2022"
//        szdlhsdw: "6"
//        tybxje: "218038.00"
//        xzkmdm: "596"
//        ysly: "0"
//        ysxm: "580666"
//        zcdfczbkxm: ""
//        zcqd: "0"
//        bmjjzcfl: "30102"
//        detaileId: 2
//        fzysrfl: ""
//        jbbm: "6"
//        nd: "2022"
//        szdlhsdw: "6"
//        tybxje: "63763.00"
//        xzkmdm: "596"
//        ysly: "0"
//        ysxm: "580666"
//        zcdfczbkxm: ""
//        zcqd: "0"
//        bmjjzcfl: "30102"
//        detaileId: 3
//        fzysrfl: ""
//        jbbm: "6"
//        nd: "2022"
//        szdlhsdw: "6"
//        tybxje: "75760.00"
//        xzkmdm: "596"
//        ysly: "0"
//        ysxm: "580666"
//        zcdfczbkxm: ""
//        zcqd: "0"

//        bmjjzcfl: "30102"
//        detaileId: 4
//        fzysrfl: ""
//        jbbm: "6"
//        nd: "2022"
//        szdlhsdw: "6"
//        tybxje: "328462.00"
//        xzkmdm: "596"
//        ysly: "0"
//        ysxm: "580666"
//        zcdfczbkxm: ""
//        zcqd: "0"

//        bmjjzcfl: "30102"
//        detaileId: 5
//        fzysrfl: ""
//        jbbm: "6"
//        nd: "2022"
//        szdlhsdw: "6"
//        tybxje: "23617.65"
//        xzkmdm: "596"
//        ysly: "0"
//        ysxm: "580666"
//        zcdfczbkxm: ""
//        zcqd: "0"
//        Map<String, String>[] param2 = new HashMap[2];
//        param2[0] = new HashMap<>();
//        param2[0].put("jbbm", "6");
//        param2[0].put("szdlhsdw", "6");
//        param2[0].put("zcqd", "0");
//        param2[0].put("ysly", "0");
//        param2[0].put("nd", "2022");
//        param2[0].put("bmjjzcfl", "30102");
//        param2[0].put("fzysrfl", "");
//        param2[0].put("zcdfczbkxm", "");
//        param2[0].put("detaileId", "5");
//        param2[0].put("xzkmdm", "596");
//        param2[0].put("tybxje", "23617.65");
//        param2[0].put("ysxm", "580666");
//        param2[1] = new HashMap<>();
//        param2[1].put("jbbm", "6");
//        param2[1].put("szdlhsdw", "6");
//        param2[1].put("zcqd", "0");
//        param2[1].put("ysly", "0");
//        param2[1].put("nd", "2022");
//        param2[1].put("bmjjzcfl", "30102");
//        param2[1].put("fzysrfl", "");
//        param2[1].put("zcdfczbkxm", "");
//        param2[1].put("detaileId", "4");
//        param2[1].put("xzkmdm", "596");
//        param2[1].put("tybxje", "328462.00");
//        param2[1].put("ysxm", "580666");
//        SubmitAmountVerificationApi api2 = new SubmitAmountVerificationApi();
//        System.err.println(api2.subDetailedCheck(param2));
//
//        BudgetSectionIncomeApi api3 = new BudgetSectionIncomeApi();
//        Map<String, Object> param3 = new HashMap<>();
//        param3.put("nf","2021");
//        param3.put("dw","");
//        param3.put("jz","yqndsjjzje");
//        System.err.println(api3.getBudgetIncomeList(param3));

//        Reimbursementlist api4 = new Reimbursementlist();
//        Map<String, Object> param4 = new HashMap<>();
//        param4.put("requestId","753755");
//        System.err.println(api4.from(param4));

        //List<String> jisijuXjId = DataBaseUtil.getSupSubcomIdBySubId("29");
        //System.err.println(Joiner.on(",").join((Iterable<?>) jisijuXjId));

//        TheCashierToPay api5 = new TheCashierToPay();
//        Map<String, Object> param5 = new HashMap<>();
//        param5.put("sqrq", "");
//        param5.put("departmentId", "");
//        param5.put("startTime", "");
//        param5.put("stopTime", "");
//        param5.put("startperform", "");
//        param5.put("endperform", "");
        //System.err.println(api5.list(param5));

//        BudgetExecutionNotice api6 = new BudgetExecutionNotice();
//        Map<String, Object> param6 = new HashMap<>();
//        param6.put("requestId", "715458");
//        System.err.println(api6.budgetMaster(param6));
//        System.err.println(api6.getBudgetSourceInfo(param6));

//        Map<String, Object> param7 = new HashMap<>();
//        param7.put("year", "");
//        param7.put("dw", "");
//        param7.put("starTime", "");
//        param7.put("endTime", "");
//        param7.put("agent","769244");
//        param7.put("jbrId", "");
//        param7.put("startMoney", "929820.28");
//        param7.put("endMoney", "929820.28");
        //System.err.println(api7.getlist(param7));
//
//        BudgetSectionItemListApi api8 = new BudgetSectionItemListApi();
//        Map<String, Object> param8 = new HashMap<>();
//        param8.put("nf", "2022");
//        param8.put("sbdw", "");
//        System.err.println(api8.getProjectList(param8));

        //testWF1();

        //ImportExcelApiV2 api9 = new ImportExcelApiV2();
        //Map<String, String> param9 = new HashMap<>();
        //param9.put("file","55383");//55352
//        ExcelDao excelDao = new ExcelDao();
//        excelDao.getSheet1Data(55371);
//        excelDao.getExceSheet4(55371);
        //api9.getExcel(param9);

        //teseWF2();
//
//        Map<String, String>[] param10 = new HashMap[1];
//        param10[0] = new HashMap<>();
//        param10[0].put("ysxm", "1197400");
//        param10[0].put("bxr", "10757");
//        param10[0].put("detaileId", "0");
//        param10[0].put("money", "996.6");
//        UserQuotaCheckApi api10 = new UserQuotaCheckApi();
//        System.err.println(api10.quotaCheck(param10));

//        HeadcquartersApi api11 = new HeadcquartersApi();
//        Map<String, Object> param11 = new HashMap<>();
//        param11.put("requestId","855855");
//        System.err.println(api11.getHeadquarters(param11));

//        BaoXiaoJiLu api12 = new BaoXiaoJiLu();
//        Map<String, Object> param12 = new HashMap<>();
//        param12.put("year","");
//        param12.put("dw","");
//        param12.put("starTime","");
//        param12.put("endTime","");
//        param12.put("startperform","");
//        param12.put("endperform","");
//        param12.put("jbrId","");
//        param12.put("agent","818818,811813,743356,749472,704870,731015,731016,710024,710029,691487,702791,711070");
//        param12.put("startMoney","");
//        param12.put("endMoney","");
//        api12.baoXiaoJiLuList(param12);

//        ProjectDetailsApi api13 = new ProjectDetailsApi();
//        Map<String, Object> param13 = new HashMap<>();
//        param13.put("requestId","582458");
//        System.err.println(api13.DetailsData(param13));

//        SubmitAmountVerificationApi api14 = new SubmitAmountVerificationApi();
//        Map<String, String>[] param14 = new HashMap[1];
//        param14[0] = new HashMap<>();
//        param14[0].put("jbbm", "259");
//        param14[0].put("szdlhsdw", "29");
//        param14[0].put("zcqd", "0");
//        param14[0].put("ysly", "1");
//        param14[0].put("nd", "2022");
//        param14[0].put("bmjjzcfl", "31006");
//        param14[0].put("fzysrfl", "");
//        param14[0].put("zcdfczbkxm", "");
//        param14[0].put("detaileId", "0");
//        param14[0].put("xzkmdm", "439");
//        param14[0].put("tybxje", "1215299.40");
//        param14[0].put("ysxm", "598085");
//        System.err.println(api14.subDetailedCheck(param14));

//        BudgetingListAction action = new BudgetingListAction();
//        Map<String, Object> param13 = new HashMap<>();
//        param13.put("requestId","657970,606686,876363,591928,661696,598087,612255,612279,607443,609688,607585,602841,589819,590065,598635,598638,645854,690594,730040,607545,776638,776638");
//        param13.put("pageNum",1);
//        param13.put("pageSize",10);
//        param13.put("ysnd","");
//        param13.put("sydw","");
//        param13.put("xm","");
//       System.err.println(action.budgetList(param13));

//        Map<String, Object> departmentBudgetadjustment = BudgetModifyDao.getDepartmentBudgetadjustment(null, "1453327", "598262", "2");
//        System.err.println(BudgetModifyDao.getmxb("598262"));
//        System.err.println(departmentBudgetadjustment);

//        RecordSetTrans rst = new RecordSetTrans();
//        rst.setAutoCommit(false);
//        boolean result = rst.executeUpdate("UPDATE uf_jingfei_version SET yszje=yszje-(?) WHERE id=?",-100.12,377);
//        System.err.println(result);

//        System.err.println(getSuperiorId("62"));
//        SyncAssetsInfoToEcology syncAssetsInfoToEcology = new SyncAssetsInfoToEcology();
//        syncAssetsInfoToEcology.setFormmodeid("101");
//        syncAssetsInfoToEcology.setdataSourceName("zongshudongtai");
//        syncAssetsInfoToEcology.start();

        Pattern pattern = Pattern.compile("[0-9]*");

//
//        AdministrationApi3 api3 = new AdministrationApi3();
//        Map<String, Object> param13 = new HashMap<>();
//        param13.put("nf","2022");
//        param13.put("jz","");
//        System.err.println(api3.getAdministrationList(param13));
//
//        OperationAuthorityApi authorityApi = new OperationAuthorityApi();
//        Map<String, Object> param14 = new HashMap<>();
//        param14.put("id","12880");
//        System.err.println(authorityApi.getAuthType(param14));

        
    }

    /**
     * 根据id获取中央下级收入的所有上级id 包含本身以及对应的科目级id
     * @param id
     * @return
     */
    public static List<String> getSuperiorId(String id){
        List<String> list = new ArrayList<>();
        RecordSet rs = new RecordSet();
        String sql = " select sjzxsr,szgnkm from  uf_zyczbksr_xj where id = "+id+" ";
        rs.executeQuery(sql);
        rs.next();
        if (StrUtil.isNotEmpty(rs.getString("sjzxsr"))){
            List<String> sjzxsr = getSuperiorId(rs.getInt("sjzxsr")+"");
            list.addAll(sjzxsr);
        }
        list.add(String.valueOf(id));
//        if(!list.contains(rs.getString("szgnkm"))){
//            list.add(rs.getString("szgnkm"));
//        }
        return list;
    }
}
